<template>
	<view class="j_cont">
		<!-- 导航栏 -->
		<view class="j_top">
			<!-- 跳转图标 -->
			<view class="j_left_icon">
				<text @click="back()">&lt;</text>
			</view>
			<!-- 标题 -->
			<view class="j_title">
				收货地址
			</view>
			<!-- right -->
			<view class="j_ttip">
				<text @click="release">确定</text>
			</view>
		</view>
		<!-- 设置收货地址 -->
		<view class="j_region">
			<view class="j_reglift">
				<text v-if="one">请输入地址</text>
				<text v-if="two">
					{{this.city[0].label}} {{this.city[1].label}} {{this.city[2].label}}
				</text>
			</view>
			<view class="j_right" @click="show = true">&gt;</view>
			<u-select v-model="show" mode="mutil-column-auto" :list="list" @confirm="confirm"></u-select>
		</view>
		<!-- 详细收货地址 -->
		<view class="j_detailed">
			<u-input v-model="value" type="text" placeholder="请输入详细地址,详细地址最多40字" maxlength="40" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//登录页传递过来id
				id: undefined,
				show: false,
				list: [{
						value: 1,
						label: '中国',
						children: [{
								value: 2,
								label: '广东',
								children: [{
										value: 3,
										label: '深圳'
									},
									{
										value: 4,
										label: '广州'
									}
								]
							},
							{
								value: 5,
								label: '广西',
								children: [{
										value: 6,
										label: '南宁'
									},
									{
										value: 7,
										label: '桂林'
									}
								]
							}
						]
					},
					{
						value: 8,
						label: '美国',
						children: [{
							value: 9,
							label: '纽约',
							children: [{
								value: 10,
								label: '皇后街区'
							}]
						}]
					}
				],
				city: '',
				//显示未输入时
				one: true,
				//显示已经输入
				two: false,
				// 详细的位置
				value: ''
			}
		},
		methods: {
			release() {
				if (this.value != '') {
					this.$api.addressUpMsg({
						id: this.id,
						address: this.city[0].label + this.city[1].label + this.city[2].label + this.value
					}).then(res => {
						console.log(res)
					})
				}
			},
			//获取你选择的地区
			confirm(e) {
				this.city = e
				this.one = false,
				this.two = true
			},
			//返回上一级页面
			back() {
				// uni.reLaunch({
				// 	url:'/pages/person/person'
				// })
				uni.navigateBack({
					data:1
				})
			},
		},
		//获取你要更改数据的id
		onLoad(option) {
			this.id = option.id
		}
	}
</script>

<style lang="scss" scoped>
	//主体验证
	.j_cont {
		width: 100%;
		height: 100vh;
		background: #F2F2F2;

		//导航栏
		.j_top {
			width: 100%;
			height: 80upx;
			background: white;
			padding: 0 20upx;
			box-sizing: border-box;
			line-height: 80upx;
			display: flex;
			margin-bottom: 20upx;

			//left
			.j_left_icon {
				width: 10%;
				height: 100%;

				font-size: 40upx;
				text-align: center;
			}

			//title
			.j_title {
				width: 70%;
				height: 100%;
				text-align: center;
			}

			//right
			.j_ttip {
				width: 20%;
				height: 100%;
				text-align: center;
				color: #999999;
				font-size: 30upx;
			}
		}
	}

	//设置地址位置样式
	.j_region {
		width: 100%;
		height: 100upx;
		background: white;
		display: flex;

		.j_reglift {
			width: 90%;
			height: 100%;
			text-align: left;
			text-indent: 20upx;
			line-height: 100upx;
		}

		.j_right {
			width: 10%;
			height: 100%;
			text-align: center;
			line-height: 100upx;
			font-size: 30upx;

		}
	}

	//设置详细位置
	.j_detailed {
		width: 100%;
		background: white;
		border-top: 2upx solid #999999;
		padding: 10upx 20upx;
	}
</style>
